package com.qhm123.spark.restlet;

import java.io.File;
import java.io.IOException;

import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;

public class BoooooApplication extends Application {

	private Configuration configuration;

	@Override
	public Restlet createInboundRoot() {
		configuration = new Configuration();
		// configuration.setTemplateLoader(new
		// ContextTemplateLoader(getContext(),
		// "clap://class/templates"));
		try {
			// TODO: 更改路径
			configuration.setDirectoryForTemplateLoading(new File(
					"/home/mingq/workspace/Booooo/template"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		configuration.setObjectWrapper(new DefaultObjectWrapper());

		Router router = new Router(getContext());
		router.attachDefault(DefaultResouce.class);

		return router;
	}

	public Configuration getConfiguration() {
		return configuration;
	}
}
